#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project: DataStructure-Python
@File: Stack.py
@Author: Dragon Geek
@Date: 2021/4/19 10:15
@Description: Bubble Sort Algorithm
"""


class Stack(object):
    def __init__(self):
        self.__list = []

    # 添加一个新的元素item到栈顶
    def push(self, item):
        self.__list.append(item)

    # 弹出栈顶元素
    def pop(self):
        return self.__list.pop()

    # 返回栈顶元素
    def peek(self):
        if self.__list:
            return self.__list[-1]
        else:
            return None

    # 判断栈是否为空
    def is_empty(self):
        return self.__list == []
        # return not self.__list

    # 返回栈的元素个数
    def size(self):
        return len(self.__list)


if __name__ == "__main__":
    Stack_01 = Stack()
    print(Stack_01.is_empty())
    print(Stack_01.size())
    Stack_01.push(1)
    Stack_01.push(2)
    Stack_01.push(3)
    Stack_01.push(4)
    print(Stack_01.is_empty())
    print(Stack_01.size())
    print("栈顶元素:", Stack_01.peek())
    Stack_01.pop()
    print("栈顶元素:", Stack_01.peek())
    Stack_01.pop()
    print("栈顶元素:", Stack_01.peek())